// 选择排序示例：
Array.prototype.selectionSort = function () {
    for (let i = 0; i < this.length - 1; i++) {
        let indexMin = i
        for (let j = i; j < this.length; j++) {
            if (this[j] < this[indexMin]) {
                indexMin = j
            }
        }
        if (indexMin !== i) {
            const temp = this[i]
            this[i] = this[indexMin]
            this[indexMin] = temp
        }
    }
    console.log(this)
}
const arr = [5, 4, 3, 2, 1]
arr.selectionSort()
// 选择排序时间复杂度为n^2，选择排序性能一般